//
// Created by Semir on 2020/5/1.
//

#include <iostream>
#include <map>
#include <vector>
#include <set>

using namespace std;

const int MODE = 80112002;
int aniNum, relNum;
map<int, vector<int>> chainMap;
vector<long long> rec;
set<int> consumers;

long long countChainNum(int index) {
    if (rec[index] > 0) {
        return rec[index];
    }
    //如果是食物链低端的生产者 返回0
    if (chainMap.count(index) == 0) {
        rec[index] = 1;
        return 1;
    }
    long long chainNum = 0;
    for (int i = 0; i < chainMap[index].size(); i++) {
        chainNum += countChainNum(chainMap.at(index).at(i));
        chainNum %= MODE;
    }
//    chainNum %= MODE;
    rec[index] = chainNum;
    return chainNum;
}

int main() {
    cin >> aniNum >> relNum;
    rec.clear();
    rec.resize(aniNum + 1, 0);
    int tmpA, tmpB;
    for (int i = 1; i <= aniNum; i++) {
        consumers.insert(i);
    }
    for (int i = 0; i < relNum; i++) {
        cin >> tmpA >> tmpB;
        chainMap[tmpB].push_back(tmpA);
        if (consumers.count(tmpA) != 0) {
            consumers.erase(tmpA);
        }
    }
    long long res = 0;
    for (set<int>::iterator iter = consumers.begin(); iter != consumers.end(); iter++) {
        res += countChainNum(*iter);
        res %= MODE;
    }
    cout << res << endl;
    return 0;
}